<template>
	<view class="sbox">
		
		
		
		<view class="card" v-if="!show">
			<view class="title">
				<!-- 点击微信或QQ自动生成邀请链接 -->
				复制链接或保存图片分享
			</view>
			<view class="imglist">
			<!-- 	<view class="item" @click="toSharewx">
					<image src="@/static/images/share/icon1.png" class="ico" mode="aspectFit"></image>
					<view class="ti-external-link">
						微信
					</view>
				</view>
				<view class="item" @click="toShareqq">
					<image src="@/static/images/share/icon2.png" class="ico" mode="aspectFit"></image>
					<view class="ti-external-link">
						QQ
					</view>
				</view> -->
				<view class="item" @click="toCopy">
					<image src="@/static/images/share/icon3.png" class="ico" mode="aspectFit"></image>
					<view class="ti-external-link">
						复制链接
					</view>
				</view>
				<view class="item" @click="DraeImg()">
					<image src="@/static/images/share/icon4.png" class="ico" mode="aspectFit"></image>
					<view class="ti-external-link">
						生成海报
					</view>
				</view>
				
			</view>
		</view>

	<XQ-GeneratePoster ref="draw" :info='option'  v-if="show" :share='show' @close="close"/>
	</view>
</template>

<script>
	import XQGeneratePoster from '@/components/friendCard.vue'
	import { mapState, mapMutations } from 'vuex'
	export default {
		name:"shareCard",
		components:{XQGeneratePoster},
		computed: {
			...mapState(['userInfo'])
		},
		props:{
			data:{
				type:Object
			}
		},
		data() {
			return {
				show:false,
				canvasW:375,
				canvasH:400,
				option: {}
			};
		},
		onShow() {
		
		},
		methods:{
			close(e){
				this.show = e
			},
			toCopy(){
					uni.setClipboardData({
									data: this.data.poster_url,
									success: () => {
										uni.showToast({
											icon: 'none',
											title: '复制成功'
										});
									}
				});
			},
			toSharewx(){
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 0,
					href: this.data.poster_url,
					title: "NFT分享",
					summary: "我正在使用，赶紧跟我一起来体验！",
					imageUrl: "https://pro.jrxtiejin.comom/index/o/logo.png",
					success: function (res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function (err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			},
			toShareqq(){
				uni.share({
					provider: "qq",
					scene: "WXSceneSession",
					type: 0,
					href: this.data.poster_url,
					title: "NFT分享",
					summary: "我正在使用，赶紧跟我一起来体验！",
					imageUrl: "https://pro.jrxtiejin.comom/index/o/logo.png",
					success: function (res) {
						console.log("success:" + JSON.stringify(res));
					},
					fail: function (err) {
						console.log("fail:" + JSON.stringify(err));
					}
				});
			},
			DraeImg(){
				this.show=true
				this.option=this.data
				this.option.nickName=this.userInfo.nickname||'疯传数藏'
				// this.option.codeUrl=this.userInfo.portrait
				console.log('----------',this.option);
				 // this.$refs.draw.share_qrcode(this.option);
				// uni.showToast({
				// 	icon: 'none',
				// 	title: '敬请期待'
				// });
				// this.show=true
				// let ctx = uni.createCanvasContext('mini_poster', this)
				// ctx.fillStyle="#0000ff";
				// ctx.fillRect(20,20,150,100);
				// ctx.setFillStyle('#FFFFFF')
				// // ctx.font('无限眼之天空之镜')
				// ctx.stroke();
				// ctx.draw()
				
			},
			SaveImg(){},
			
		}
	}
</script>

<style lang="scss" scoped>
	.sbox{
		
	}
	.card{
		width: 100%;
		// height: 408rpx;
		background: #1E2020;
		border-radius: 32rpx 32rpx 0px 0px;
		padding: 60rpx 0rpx;
		.title{
			font-size: 28rpx;
			font-weight: 600;
			color: #C1C1C1;
			line-height: 40rpx;
			margin:0rpx 64rpx;
		}
		.imglist{
			display: flex;
			align-items: center;
			justify-content: space-around;
			    width: calc(100% - 128rpx);
				margin: 58rpx auto 0;
			.item{
				display: flex;
				flex-direction: column;
				align-items: center;
				.ico{height: 88rpx;width: 88rpx; }
				.ti-external-link{
					font-size: 28rpx;
					font-weight: 600;
					color: #C1C1C1;
					line-height: 40rpx;
					margin-top: 22rpx;
					margin-bottom: 40rpx;
				}
			}
		}
	}
	.box{
		background: #000000;
		height: 500rpx;
		// position: absolute;
		// top: 0%;
		// left: 0%;
		// transform: translate(-50%, -50%);
		
	}
</style>
